Repository navigation
Conversation
There was a problem hiding this comment.
Indeed, linking geojson to marker cluster is broken at the moment. To be honest I didn't know we offered that functionality. Thanks for the well-written problem description.
I tried your fix, but it seems it breaks LayerControl when using GeoJson normally and with non-embedded data. While looking into this I came up with an alternative approach. I'll make a PR, maybe you can check it out, let me know what you think? #1190 Then we can discuss how to move on.
| }}); | ||
| var json_url = $.ajax({url: {{ this.embed_link|tojson }}, dataType: 'json', async: true }) | ||
| $.when(json_url).done(function() { | ||
| var geo_json_32b06f4a0e6d419c8f501b4e6c43bc57 = L.geoJson(json_url.responseJSON |
There was a problem hiding this comment.
The problem with this is that this breaks LayerControl for regular geojson use cases. This variable has to be declared and defined outside of the ajax call.
There was a problem hiding this comment.
Yes, in fact it breaks. I wasn't aware of it. I just tried your PR and works as expected 👍
| {%- endif %} | ||
| }).addTo({{ this._parent.get_name() }}); | ||
| var options = { | ||
| {%- if this.smooth_factor is not none %} |
There was a problem hiding this comment.
Why do you remove the indentation here?
There was a problem hiding this comment.
May be automatic linting, I didn't see it. Sorry
| {{ this.get_name() }}.addData(data); | ||
| }}); | ||
| var json_url = $.ajax({url: {{ this.embed_link|tojson }}, dataType: 'json', async: true }) | ||
| $.when(json_url).done(function() { |
There was a problem hiding this comment.
You can link this to the ajax call directly: $.ajax().done(function() {});
There was a problem hiding this comment.
Have you tried? Because the problem I had was related with async ajax request and because of that I used a variable to check if the request was finished. I don't have experience with JS. I just searched about it and I found that solution in a blog post.
There was a problem hiding this comment.
It seems to work here, and is also listed in the examples in the jQuery documentation, so assume it should be fine.
|
This problem has been fixed in #1190. |
This PR fixed #1129
My understating of the cause of this issue is because we are currently adding a geojson with a null value to cluster marker layer and only later adding the geojson data.
folium/folium/features.py
Line 416 in 2122625
And because of this, the following code produces a empty map:
The
cluster.htmlhtml code:However, with the same python code, if we change the html code and add the geojson data at the same time we create the geojson layer, as bellow, the markers are displayed on map.
This PR fixed this issue and at the same time makes it possible have data not embed on html file when an url is passed as data source.